// 混入文件
import {
	ref
} from 'vue'
//获取状态栏和胶囊区的高度
export const systemInfo = () => {
	const statusHeight = ref(0); //状态栏高度
	const capsuleHeight = ref(0); //胶囊区域高度
	//获取系统信息
	const getSystemMessage = async () => {
		//获取状态栏高度
		const res = await uni.getSystemInfo();
		statusHeight.value = res.statusBarHeight;
		//获取胶囊区域信息
		const menu = uni.getMenuButtonBoundingClientRect();
		//计算获得导航栏高度
		capsuleHeight.value = menu.height + (menu.top - statusHeight.value) * 2;
	};
	getSystemMessage()
	return {
		statusHeight,
		capsuleHeight
	}
}

//获取页面滚动事件
export const getPageScroll = () => {
	const scrollHeight = ref(0)
	const onScroll = async (e) => {
		scrollHeight.value = e.target.scrollTop
	}
	return {
		scrollHeight,
		onScroll
	}
}